package com.fagertveit.android.game.cb;

import com.fagertveit.android.game.framework.geom.AABB;

public class Pad {
	private static float[] PAD_SIZE = {32.0f, 48.0f, 64.0f, 80.0f, 96.0f};
	private float posX;
	private int size;
	private AABB shape;
	
	public Pad() {
		posX = 256.0f;
		size = 2;
		shape = new AABB(256.0f, 448.0f, 32.0f, 8.0f);
	}
	
	public void setX(float posX) {
		this.posX = posX;
	}
	
	public float getX() {
		return posX;
	}
	
	public float getDrawX() {
		return posX - PAD_SIZE[size]/2;
	}
	
	public void update(float acc) {
		posX += acc;
		if(posX > 452 - (PAD_SIZE[size]/2)) {
			posX = 452 - (PAD_SIZE[size]/2);
		} else if(posX - (PAD_SIZE[size]/2) < 16) {
			posX = 16 + (PAD_SIZE[size]/2);
		}
		shape.setPos(posX, 448);
	}
	
	public void setSize(int size) {
		this.size = size;
	}
	
	public int getSize() {
		return size;
	}
	
	public AABB getShape() {
		return shape;
	}
}
